//
//  CHUUIDManager.m
//  SZTZ
//
//  Created by 陈浩 on 2017/6/8.
//  Copyright © 2017年 陈浩. All rights reserved.
//

#import "CHUUIDManager.h"
#import "CHKeyChain.h"
@implementation CHUUIDManager

static NSString * const KEY_IN_KEYCHAIN = @"com.logrise.SZTZ";
static NSString * const KEY_IN_KEYCHAIN_NAME = @"com.logrise.SZTZ_NAME";

static NSString * const KEY_UUID = @"com.logrise.SZTZ.uuid";
static NSString * const KEY_USERNAME = @"com.logrise.SZTZ.username";

+(void)saveUUID:(NSString *)uuid
{
    NSMutableDictionary *usernameUuidPairs = [NSMutableDictionary dictionary];
    [usernameUuidPairs setObject:uuid forKey:KEY_UUID];
    [CHKeyChain save:KEY_IN_KEYCHAIN data:usernameUuidPairs];
}


+(void)saveUserName:(NSString *)username
{
    NSMutableDictionary *usernameUuidPairs = [NSMutableDictionary dictionary];
    [usernameUuidPairs setObject:username forKey:KEY_USERNAME];
    [CHKeyChain save:KEY_IN_KEYCHAIN_NAME data:usernameUuidPairs];
    
}

+(id)readUserName
{
    NSMutableDictionary *usernameUuidPairs = (NSMutableDictionary *)[CHKeyChain load:KEY_IN_KEYCHAIN_NAME];
    return [usernameUuidPairs objectForKey:KEY_USERNAME];
}


+(id)readUUID
{
    NSMutableDictionary *usernameUuidPairs = (NSMutableDictionary *)[CHKeyChain load:KEY_IN_KEYCHAIN];
    return [usernameUuidPairs objectForKey:KEY_UUID];
}

+(void)deleteUUID
{
    [CHKeyChain delete:KEY_IN_KEYCHAIN];
}

@end
